package com.foreknow.Bnak;

import java.util.Scanner;

/**
 * @author shkstart
 * @create 2021-07-22 15:46
 */
public class Bank {
    String user = "root";
    String pass = "root";
    double balance = 10000;
    //初始化账户信息
    String userid;
    String userpas;
    public static void welcome() {
        System.out.println("***** 欢迎登录  ******");
        System.out.println("***** 中国人民银行  ******");
        System.out.println("*****  版本1.0  ******");
        System.out.println("-------------------");
    }

    public static boolean login(String userid, String pass) {
        boolean flag=false;
        Scanner sc=new Scanner(System.in);
        for (int i = 3; i >0 ; i--) {
            System.out.println("请输入用户名");
            String id= sc.next();
            System.out.println("请输入密码");
            String password= sc.next();

            if(id.equals(userid)&&password.equals(pass)){
                flag=true;
                break;
            }else{
                System.out.println("用户名或者密码错误，请重新输入，您还有"+(i-1)+"次机会");
                flag=false;

            }
            if(i==1){
                System.out.println("吞卡");
                System.exit(0);

            }

        }
        return flag;
    }
    public static  char mainview(){
        System.out.println("1.查询余额\t2.存款\t3.取款\t4.修改密码\t5.退出");
        System.out.println("请选择");
        Scanner sc=new Scanner(System.in);
        String a=sc.next();
        char c=a.charAt(0);
        return c;
    }
    /**
     * 查询余额
     */
    public static void selectbalance() {

    }

    /**
     * 修改密码
     */
    public static  void changePassward() {

    }

    /**
     * 取款
     */
    private static void withdrawal() {

    }

    /**
     * 存款
     */
    private static  void deposit() {


    }

    /**
     * 是否继续操作
     *
     * @return
     */
    public static boolean goon() {
        Scanner sc = new Scanner(System.in);
        System.out.println("是否继续操作（y/n）");
        String key=sc.next();
        char k=key.charAt(0);
        if (k == 'Y') {
            return true;
        } else {
            return false;
        }
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String user = "root";
        String pass = "root";
        boolean loopFlag=true;
        //登录界面
        welcome();
        boolean issuccess=login(user,pass);
        if (issuccess){
            while (true){
                char c=mainview();
                switch (c){
                    case '1':
                        selectbalance();
                        loopFlag = goon();
                        break;
                    case '2':
                        deposit();
                        loopFlag = goon();
                        break;
                    case '3':
                        withdrawal();
                        loopFlag = goon();
                        break;
                    case '4':
                        changePassward();
                        loopFlag = goon();
                        break;
                    case '5':
                        System.out.print("确认是否退出(Y/N)：");
                        String s1=sc.next();
                        char s=s1.charAt(0);
                        if (s == 'Y')
                            loopFlag = false;
                        break;

                }

            }


        }

    }
}
